---
title: "Gorilla Home Range"
output:
flexdashboard::flex_dashboard:
social: menu
source_code: embed
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file())
library(flexdashboard)
library(DT)
library(ggplot2)
library(plotly)
```
# Main Page
## Column {data-width=300}
###
This dashboard is an analysis tool to compute and visualize home range data of Mountain Gorillas collected by GNSS sensors from [Dian Fossey Gorilla Fund International](https://gorillafund.org/). The observed Gorillas are located at the Volcanoes National Park, Rwanda. This analysis tool enables:
- Compute home range sizes, walking distances, and overlap areas
- Export statistical data tables and spatial results
- Data visualization of home range analysis
License: https://creativecommons.org/licenses/by-nc/3.0/
Author: [Ka Hei Chow](http://students.eagle-science.org/students/students-2020/ka-hei/)
{width=70%}
## Column {data-width=700}
###
```{r picture, echo = F, out.width = '100%'}
knitr::include_graphics("https://splendoursofafricatours.com/uploads/destination_detail/22/volcanoes-Park-Rwanda-Banner.jpg")
```
```{r}
source("analysisFunctions.R")
```
# Data Availability
## {data-width=200}
###
This panel displays the availability of GNSS data for each Gorilla group.
##
# Statistics {data-navmenu="Home Range"}
## {data-width=200}
###
The collected GNSS data is used to calculate the home range of the Mountain Gorillas using Kernel density estimator with bivariate normal kernel using 95% of estimated distribution. Key statistics by Gorilla group are shown in this panel.
```{r, echo = F}
csv <- "Gorilla_ranging_Jan_May_21.csv"
df <- GPS2df(csv)
total_home_range <- round(ttlHR(df),1)
areadf <- gpHR(df)
max_area <- round(max(areadf$area),1)
min_area <- round(min(areadf$area),1)
mean_area <- round(mean(areadf$area),1)
```
## {data-width=300}
### Max Size (km²)
```{r}
valueBox(max_area, icon="ion-stats-bars", color="#5f8111")
```
### Min Size (km²)
```{r}
valueBox(min_area, icon="ion-stats-bars", color="#a3ca61")
```
### Mean Size (km²)
```{r}
valueBox(mean_area, icon="ion-android-home", color="#5f8111")
```
### Total Coverage (km²)
```{r}
valueBox(total_home_range, icon="ion-android-locate", color="#a3ca61")
```
## {data-width=500}
### Home Range Size Data Table
```{r functions}
nice_datatable <- function(df, caption = NULL, ...) {
df %>%
datatable(
extensions = c("Buttons", "FixedHeader", "Scroller"),
filter = "top",
rownames = FALSE,
escape = FALSE,
caption = caption,
options =
list(
dom = "Brtip",
deferRender = FALSE,
scrollY = 300,
scroller = TRUE,
scrollX = TRUE,
fixedHeader = FALSE,
buttons = c("copy", "csv"),
pageLength = nrow(df),
lengthChange = FALSE,
...
)
)
}
```
```{r}
nice_datatable(areadf %>% mutate_if(is.numeric, round, 2))
```
# Map {data-navmenu="Home Range"}
## {data-width=600}
###
```{r}
#Interactive Map
map <- mapDisplay(df)
map@map %>% setView(29.49, -1.5, zoom = 13)
```
## {data-width=400}
###
```{r}
#Overview Map
knitr::include_graphics("https://www.berggorilla.org/fileadmin/_processed_/4/e/csm_volcano_national_park_f577bb5a63.png")
```
###
```{r}
#Bar Chart: Home Range Size
fig1 <- areaBar(areadf)
ggplotly(fig1, tooltip=c("x","y")) %>% config(displayModeBar = FALSE)
```
# Group Dynamics
## {data-width=200}
This panel display information about how home range of different Mountain Gorilla groups overlap with each other. It includes a heatmap showing the interactions among groups, as well as a scatter plot to illustrate the relationship between home range size and total share of home range.
## {data-width=500}
###
```{r}
fig2 <- overlapBar(df)
ggplotly(fig2, tooltip=c("y")) %>% config(displayModeBar = FALSE)
```
###
```{r}
fig3 <- dynamicViz(df)
ggplotly(fig3) %>% config(displayModeBar = FALSE)
```
## {data-width=300} {.tabset }
### Interactions
```{r}
# Tab 2
#fig4 <- GPheatmap(df)
#fig4
invisible(GPheatmap(df))
```
### Data Table
```{r}
# Tab 1
gp_dyn_df <- overlapAnalysis(df)
names(gp_dyn_df) <- c("Primary Group","Home Range Size of Primary Group","Interacting Group","Home Range Overlapped Area","Percentage to Size of Primary Group")
nice_datatable(gp_dyn_df %>% mutate_if(is.numeric, round, 2))
```
# Walking Distance
###
```{r}
```
# References
###
- Calenge C (2006). “The package adehabitat for the R software: tool for the analysis of space and habitat use by animals.” Ecological Modelling, 197, 1035.
- Tétreault, M., Franke, A. (2017). Home range estimation: examples of estimator effects. Applied raptor ecology: essentials from Gyrfalcon research. The Peregrine Fund, Boise, Idaho, USA, 207-242.
- Walter,D., Fischer,J.W.,(2016). Home Range Estimation. In Manual of Applied Spatial Ecology (pp. 72–105). essay, Walter Applied Spatial Ecology Laboratory.